export default {
	//开启命名空间
	namespaced: true,

	//数据节点
	state: () => ({
		//定位地址
		dwAddress: uni.getStorageSync('dwAddress') || {},
		//用户信息
		userInfo: uni.getStorageSync('userInfo') || {},
		//登录方式
		isVisitorLogin: uni.getStorageSync('isVisitorLogin') || ''
	}),
	//相当于异步操作，不能直接改变state的值，可以通过触发mutations来改变
	actions: {
		//1，设置定位的值
		actUpdateDwAddressData(stateData, dwAddressObject) {
			//获取所有数据
			//var cartData = stateData.state.dwAddress
			stateData.commit('mutUpdateDwAddressData', dwAddressObject)
		},
		//2，设置用户信息
		actUpdateUserInfoData(stateData, userInfo) {
			stateData.commit('mutUpdateUserInfoData', userInfo)
		},
		//3，设置用户登录方式
		actUpdateLoginData(stateData, isVisitorLogin) {
			stateData.commit('mutUpdateLoginData', isVisitorLogin)
		}

	},

	//方法节点（相当于同步操作）
	mutations: {
		mutUpdateDwAddressData(state, dwAddressObject) {
			state.dwAddress = dwAddressObject

			//保存到本地
			uni.setStorageSync('dwAddress', dwAddressObject)
		},
		mutUpdateUserInfoData(state, userInfo) {
			state.userInfo = userInfo
			uni.setStorageSync('userInfo', userInfo)

		},
		mutUpdateLoginData(state, isVisitorLogin) {
			state.isVisitorLogin = isVisitorLogin
			uni.setStorageSync('isVisitorLogin', isVisitorLogin)
		}
	},

	getters: {
		// getMsgList(state) {
		// 	return state.msgData
		// }
	}
}